#include "description_util.h"

#include <fcntl.h>

int DescriptionUtil::DescriptionBlockStatus(int description, int block)
{
    int old_flag = fcntl(description, F_GETFL);
    if (block)
    {
        old_flag = old_flag & (~O_NONBLOCK);
    }
    else
    {
        old_flag = old_flag | O_NONBLOCK;
    }
    int result = fcntl(description, F_SETFL, old_flag);
    return result;
}
